﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NCalculator.Operations
{
    [Serializable()]
    public class MultiplicationNode : OperationNode
    {

        public MultiplicationNode()
        {
            _priority = 3;
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="left">Left value of equation</param>
        /// <param name="right">Right value of equation</param>
        public MultiplicationNode(Node left, Node right)
        {
            _left = left;
            _right = right;
            _priority = 3;
        }

        /// <summary>
        /// Calculate multiplication operation
        /// </summary>
        /// <returns>calcuated value as double</returns>
        public override double Evaluation()
        {
            return _left.Evaluation() * _right.Evaluation();
        }

        /// <summary>
        /// Convert calculated value as string
        /// </summary>
        /// <returns>string with evaluation result</returns>
        public override string ToString()
        {
            if ((_left == null) || (_right == null))
                return " * ";
            else
            {
                //return string.Format("{0} * {1} ", _left.Evaluation().ToString(), _right.Evaluation().ToString());
                return " * ";
            }
        }
    }
}
